﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cwtrock.model;
using cwtrock.view.sysmng;
using cwtrock.view.handle;

namespace cwtrock.view
{
    public partial class FrmMain : Form
    {
        private static FrmMain frm;
        private int childFormNumber = 0;
    //    public SysUsr usr;


        #region 单体模式
        /// <summary>
        /// 单体模式
        /// </summary>
        /// <returns></returns>
        public static FrmMain getInstance()
        {

            if (frm == null)
            {
                frm = new FrmMain();

            }

            return frm;
        }
        #endregion


        public FrmMain()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "窗口 " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
          //  toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
          //  statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        private void VoucherMenu_Click(object sender, EventArgs e)
        {
            VoucherFrm voufrm = VoucherFrm.getInstance();
            voufrm.Show();
        }

   
        private void 用户管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 币种ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BizhongFrm bzFrm = new BizhongFrm();
            bzFrm.Show();
        }

        private void 凭证字ToolStripMenuItem_Click(object sender, EventArgs e)
        {
           VouKeywordFrm frm = new VouKeywordFrm();
            frm.Show();
        }

        private void 解算方式ToolStripMenuItem_Click(object sender, EventArgs e)
        {
           SolverFrm frm = new SolverFrm();
            frm.Show();
        }

        private void 凭证查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            VouQueryFrm frm = VouQueryFrm.getInstance();
            if (frm != null)
            {
                frm.MyfrmMain = this;
                frm.Show();
            }
            
        }

        private void AccountInfos_Click(object sender, EventArgs e)
        {
            AccountsMainFrm acctfrm = AccountsMainFrm.getInstance("关闭");
            acctfrm.Show();
        }

        private void Vpost_msbtn_Click(object sender, EventArgs e)
        {
            Postguide_frm frm = Postguide_frm.getInstance();
            frm.Show();
        }

        private void GeneralRptMenu_Click(object sender, EventArgs e)
        {
            GeneralRptGuide frm = GeneralRptGuide.getInstance();
            frm.ShowDialog();
        }
    }
}
